<?php
@session_start();
require_once("../connect_db.php");
if(isset($_GET["temp"])){
$sqlTemp="select * from car where car_id='".$_GET["temp"]."'";
$queryTemp=mysql_query($sqlTemp);
$resultTemp=mysql_fetch_array($queryTemp);
}
?>
<form method="post" enctype="multipart/form-data" name="frmreg" id="frmreg">



<div class="row">
	<div class="col-md-12">
		<div class="panel panel-danger" >
		  <div class="panel-heading">
			<h3 class="panel-title">ข้อมูลรถ</h3>
		  </div>
		  <div class="panel-body">
			  <div class="form-group">
				<label for="inputname1" class="col-sm-5 control-label">ยี่ห้อรถ</label> 
				<div class="col-sm-7">
				  <input type="text" class="form-control" id="car_brand" name="car_brand" 
				  value="<?php if(isset($resultTemp["car_brand"])) echo $resultTemp["car_brand"]?>" placeholder="">
				  
				</div>
			  </div>
			  <div class="form-group">
				<label for="inputlastbrand" class="col-sm-5 control-label">รุ่น</label>
				<div class="col-sm-7">
				  <input type="text" class="form-control" 
				  value="<?php if(isset($resultTemp["car_model"])) echo $resultTemp["car_model"]?>" 
				  id="car_model" name="car_model"  placeholder="">
				 
				</div>
				</div>
				<div class="form-group">
				<label for="inputcolor" class="col-sm-5 control-label">สี</label>
		<div class="col-sm-7">
				  <input type="text" class="form-control" id="car_color" 
					value="<?php if(isset($resultTemp["car_color"])) echo $resultTemp["car_color"]?>"
				      name="car_color" placeholder="">
				  
				</div>
				</div>
			
				<div class="form-group">
				<label for="inputs" class="col-sm-5 control-label">ระบบเกียร์</label>
				<div class="col-sm-7">
				  <label>
				<input type="radio"  id="optionsRadios1" name="car_geartype"  value="ธรรมดา"
				<?php if(isset($resultTemp["car_geartype"])&&$resultTemp["car_geartype"]=="ธรรมดา") echo "checked"?>
				<?php if(!isset($resultTemp["car_geartype"])) echo "checked"?>
				>ธรรมดา
					</label>
					<label>
				<input type="radio"  id="optionsRadios1"  name="car_geartype" value="อัตโนมัติ"
				<?php if(isset($resultTemp["car_geartype"])&&$resultTemp["car_geartype"]=="อัตโนมัติ") echo "checked"?>
				
				>อัตโนมัติ
				
					</label>
				</div>
				</div>
				
				<div class="form-group">
				<label for="inputtel" class="col-sm-5 control-label">สมถรรนะ</label>
				<div class="col-sm-7">
				  <input type="text" class="form-control" id="car_power"
					value="<?php if(isset($resultTemp["car_power"])) echo $resultTemp["car_power"]?>"
				  name="car_power"  placeholder="">
				
				</div>
				</div>
				
					<div class="form-group">
				<label for="inputtel" class="col-sm-5 control-label">ชนิดน้ำมัน</label>
				<div class="col-sm-7">
				  <input type="text" class="form-control" id="car_fuel"
					value="<?php if(isset($resultTemp["car_fuel"])) echo $resultTemp["car_fuel"]?>"
				  name="car_fuel"  placeholder="">
				
				</div>
				</div>
				
				<div class="form-group">
				<label for="inputaddr" class="col-sm-5 control-label">ทะเบียน</label>
				<div class="col-sm-7">
				  <input type="text" class="form-control"
					value="<?php if(isset($resultTemp["car_regis"])) echo $resultTemp["car_regis"]?>"
				  id="car_regis" name="car_regis" placeholder="">
				  
				</div>
				</div>
				<input type="hidden" name="temp" id="temp" 
				<?php if(!isset($resultTemp["car_id"])) {}
				else {echo "value='".$resultTemp["car_id"]."'"; }
				?>   />
                  <div class="form-group">
				<label for="inputmail" class="col-sm-5 control-label">รูป</label>
				<div class="col-sm-7">
				  <div><img 
				 <?php if(isset($resultTemp["car_pic"])) 
				 {echo "src='../uploads/car/pics/".$resultTemp["car_pic"]."'";}
				 else 
				 {echo "src='../uploads/car/pics/no_image.jpg'";}
				 ?>
				   id="preview" width="100" height="80"  alt="" 
				  style="-webkit-box-shadow: 7px 5px 5px 0px rgba(153,151,153,1);
-moz-box-shadow: 7px 5px 5px 0px rgba(153,151,153,1);
box-shadow: 7px 5px 5px 0px rgba(153,151,153,1);" />
				  </div>
				
				</div>
				</div>
                
                <div class="form-group">
				<label for="inputmail" class="col-sm-5 control-label">รูป</label>
				<div class="col-sm-7">
				  <input type="file" name="car_pic" id="car_pic" />
				 
				</div>
				</div>
                
			  <div class="form-group">
				<div class="col-sm-offset-5 col-sm-7"><br>
                <span class="style30" id="displayAJAX"></span>
				<input type="hidden" name="temp" id="temp" 
				<?php if(!isset($resultTemp["car_id"])) {}
				else echo "value='".$resultTemp["car_id"]."'"; 
				?>   />
                <input type="button" class="btn btn-success" name="button" id="button" 
				value="
				<?php if(!isset($resultTemp["car_id"])) echo "เพิ่มรถ";
				else echo "แก้ไข"; ?>" 
				 onClick='JavaScript:validate_car_register();' />
 
				<button type="button" class="btn btn-danger" onClick="if(window.confirm('ต้องการยกเลิกกรุณายืนยัน')) {}
				$('#h3title').html('ข้อมูลรถ');
				$('#mainscreen').load('admin/manage_car_page.php');
				">ยกเลิก</button>
				</div>
				<div class="col-sm-offset-7 col-sm-4">
				  
				</div>
				
			  </div>
			 
			
		  </div>
		</div>
	</div>
</div>
</form>
<script>
$(function(){
  $("#car_pic").change(function(){
        readURL(this);
    });
});
</script>